--local g = getfenv(0)
--local addon = DongleStub"Dongle-1.0":New"MSBTPartyWarning"
local addon = CreateFrame"Frame"

addon:RegisterEvent"UNIT_HEALTH"
addon:SetScript("OnEvent", function(self, event, ...) 
	local unit = arg1
	if not addon.below then addon.below = {} end 
	if string.sub(unit, -6, 5) == "party" then
		local healthAmount = UnitHealth(unit)
		local healthPercentage = healthAmount / UnitHealthMax(unit)
		if healthPercentage < 50/100 then
			if addon.below[unit] then return end
			local name = UnitName(unit)
			local text = string.format("%s: %d (%d%%)", name, tonumber(healthAmount), math.floor(healthPercentage*100))
			MikSBT.DisplayMessage(text, MikSBT.DISPLAYTYPE_NOTIFICATION, true, 9 * 255, 9 * 255, 9 * 255, 30)
			addon.below[unit] = true
		else
			addon.below[unit] = false
		end
	end
end)
